package controllers

import java.io.File

import org.apache.commons.io.FileUtils
import play.api.libs.json.Json
import play.api.mvc.{Action, Controller}

class HelpController  extends Controller{


  def helpBefore = Action {
    Ok(views.html.help.index())
  }

  def getHelpPage(file:String,name:String) = Action{
    val windowsPath = "D:/多样性软件官网/帮助文档/VGenomics_AS/tools"
    val linuxPath = "/root/projects/fern"
    val path = {
      if (new File(windowsPath).exists()) windowsPath else linuxPath
    }
    val f = FileUtils.readFileToString(new File(path , file),"GB2312")
    val fs = file.split("/")
    val filesname = fs.last.take(fs.last.lastIndexOf('.')) + ".files"
    val b = f.replaceAll( filesname,"/assets/new_tools/" + fs.head + "/" + filesname)
    val c   = "<h1>"+name+"</h1>" +  b.replaceAll("gb2312","utf-8")
    Ok(Json.toJson(c))
  }

  def videoBefore = Action{
    Ok(views.html.videos.video())
  }

  def faq = Action{
    Ok(views.html.explain.faq())
  }

  def vgquestion = Action{
    Ok(views.html.explain.vgquestion())
  }

  def vx = Action{
    Ok(views.html.explain.wx())
  }

  def operation = Action{
    Ok(views.html.explain.operation())
  }

  def group = Action{
    Ok(views.html.explain.group())
  }

  def compare = Action{
    Ok(views.html.explain.compare())
  }

  def getData = Action{
    Ok(views.html.explain.getData())
  }

  def download = Action{
    Ok(views.html.explain.download())
  }

}
